import authorizationUtil from '@/utils/authorization-util';
import { useEffect } from 'react';
import { history } from 'umi';
const Oauth2Login = () => {

    useEffect(() => {
        // 从URL中获取accessToken
        const urlParams = new URLSearchParams(window.location.search);
        const accessToken = urlParams.get('accessToken'); // 获取accessToken参数

        if (accessToken) {
            // 将accessToken存储到localStorage
            // localStorage.setItem('accessToken', accessToken); 
            authorizationUtil.setItems({
                Authorization: accessToken,
                TokenExpireSeconds: "2"
              });     
            // 跳转到指定页面
            history.push('/chat/share?appId=1'); // 使用 umi 的 history 进行页面跳转
        }
    }, [history]);

    
    return (
        <div>Oauth2Login 正在登录...</div>
    );

}

export default Oauth2Login;